import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../main222.dart';
import '../ui/login/login_by_pwd.dart';
import '../ui/login/login_wechat.dart';
import '../ui/main/navigator.dart';

class Navigate {

  Navigate._();

  static toLogin() {
    if(kIsWeb) {
      print('11111');
      Navigator.of(navKey.currentContext!).push(MaterialPageRoute(builder: (ctx) => const LoginByWechat()));
    } else {
      print('22222');
      Navigator.of(navKey.currentState!.overlay!.context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const LoginByPwd()), (route) => route == null);
    }
  }

  static toMain() {
    Navigator.of(Get.context!).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>  AppMain()), (route) => route == null);
  }

  static Future toPage(Widget page) {
    return Navigator.push(Get.context!, CupertinoPageRoute(builder: (context){
      return page;
    }));
    return Navigator.of(navKey.currentState!.overlay!.context).push(MaterialPageRoute(builder: (ctx) => page));
  }

}